package com.ffcs.web.job;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.ffcs.web.daos.implementations.FreeAskDao;
import com.ffcs.web.model.entity.FreeAsk;
import com.ffcs.web.services.FreeAskService;
import com.ffcs.web.utils.CommonConfig;
import com.ffcs.web.utils.JsSign;

@Component
public class yuyinJob {

	@Autowired
	private FreeAskDao freeAskDao;
	@Autowired
	private FreeAskService freeAskService;
//	@Scheduled(cron = "0/59 * * * * ?")
	@Transactional
	public void yuyinJobEveryTime(){
		FreeAsk freeAsk=new FreeAsk();
		freeAsk.setType((short)1);
		freeAsk.setIsLoad((short)0);
		List<FreeAsk> list=freeAskDao.findByExample(freeAsk);
		for (FreeAsk fask : list) {
			String newMp3Name=freeAskService.main1(JsSign.getAccessToken(), fask.getQuestion(),CommonConfig.getProperty("YUYIN_ADRESS"));
			fask.setIsLoad((short)1);
			fask.setQuestion(newMp3Name);
			System.out.println("id="+fask.getId()+"微信语音已成功下载,文件名:"+newMp3Name);
		}
	}
}
